<?php
/**
 * Created by PhpStorm.
 * User: Dale
 * Date: 2017/7/3
 * Time: 14:05
 */
/* Connect to a MySQL database using driver invocation */
/**
$dsn = 'mysql:dbname=demo;host=192.168.76.11';
$user = 'root';
$password = '123456';

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$statement = $dbh->query('SELECT * FROM article');

if($statement === false) {
    die('SQL error:'.$dbh->errorInfo()[2]);
}

$list = $statement->fetchAll(PDO::FETCH_OBJ);

print_r($list);
*/

//echo date('Y-m-d H:i:s',time());


/**
 * Created by PhpStorm.
 * User: Dale
 * Date: 2017/7/4
 * Time: 10:04
 */

$dsn = 'mysql:dbname=MyBlog;host=192.168.76.11';
$user = 'root';
$password = '123456';
try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$sql="SELECT * FROM tb_article";

$statement = $dbh->query($sql);
if($statement === false ){
    die('SQL出错'.$dbh->errorInfo()[2]);
}
$rs_list = $statement->fetchAll(PDO::FETCH_ASSOC );
print_r($rs_list);
$id = 36;
foreach ($rs_list as $KEY){
    if($KEY['ID'] == $id) {
        echo $KEY['PublishTime'];
    }
}



?>
